home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 18445 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  896 b 

  1. Path: news.halcyon.com!usenet
  2. From: normanb@halcyon.com (Norm Bryar)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: A question of privacy
  5. Date: Sat, 20 Apr 1996 15:37:35 GMT
  6. Organization: Northwest Nexus Inc.
  7. Message-ID: <4lb0ag$5m6@news.halcyon.com>
  8. References: <3177F514.544E@cstar.ac.com>
  9. NNTP-Posting-Host: blv-pm2-ip16.halcyon.com
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. Asgeir Olafsson <olafsson@cstar.ac.com> wrote:
  13.  
  14. >Should the following work according to the ANSI C++
  15. >standard draft?
  16.  
  17. >// Compiles fine under VC++ 4.0
  18. >class A {
  19. >private:
  20. >    A() {}
  21. >};
  22.  
  23. >class B {
  24. >public:
  25. >    A &f() { return A();} // No complaints about privacy
  26. >};
  27.  
  28. >void g()
  29. >{
  30. >    B b;
  31. >    A a = b.f();
  32. >}
  33.  
  34.  
  35. >I suspect what is happening, is that a temporary object
  36. >is being created, so if this is legal the object could be
  37. >deleted as soon as "a" goes out of scope?
  38.  
  39. >Regards,
  40. >'Asgeir.
  41.  
  42. It looks like a VC bug to me.    --Norm
  43.  
  44.